Day 1: Getting data into shape

Tidyverse world: 1) workflow: 2) Rstudio: 3) importing data: 4) manipulating data

Ben Fanson https://bfanson.github.io/2024DADAworkshop/ (Arthur Rylah Institute)https://www.ari.vic.gov.au/
2024-09-04

Day’s objectives

  1. Understand workflow, why it is important, and how to do it using Rstudio/R
  2. Have an understanding of the tidyverse framework and its key packages
  3. Work through an example

Key packages

Example of some workflows

mine

Paul’s

Commonalities

Advantages of workflow

asfd

adsf

Dataset for workshop

For this workshop, we will you an example dataset to go through the whole workflow process.

Rstudio

You can find a variety of cheatsheets at https://posit.co/resources/cheatsheets/

Basics

Tips and tricks

Programming good technique

Tidyverse framework

Historical context

Setting up Rproject

Rproject

Project directory/folder structure

Hands-on

Your Task Setup an Rproject for the workshop study

Importing

Saving the data files

Excel files

Key functions

Show code
  readxl::read_xls()
  readxl::read_xlsx()

Tips and tricks

CSV/Table

Show code
  readr::read_csv()
  readr::read_table()

Advantages

SEtting your column types

Hands-on

After setting up the folder structure for your project, you need to add your data. Here, you will download the data/ directory using link below:

After the zip file downloads, unzip and drag the data/ folder to your Rproject folder.

XXXX data/raw, data/rds, data/spatial XXXX

Your Task

Import your data

Data cleaning

Joins

Show code
  knitr::include_graphics("lubridate.pdf")

knitr::include_graphics(“dplyr.pdf”)







Note: joins = merges (synonyms)

Tips and tricks

Your Task

Restructuring

Show code
  knitr::include_graphics("lubridate.pdf")

knitr::include_graphics(“tidyr.pdf”)







Your Task

String manipulation

Show code
  knitr::include_graphics("lubridate.pdf")

knitr::include_graphics(“stringr.pdf”)







Your Task

Date/time

Show code
  knitr::include_graphics("lubridate.pdf")







Your Task

Saving the clean data

At the end of the import and clean stage, I save the dataset as a